package cn.iocoder.yudao.module.mp.mq.consumer.message;


import cn.iocoder.yudao.module.mp.mq.message.message.SendTemplateMessage;
import cn.iocoder.yudao.module.mp.service.message.MpTemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 针对 {@link SendTemplateMessage} 的消费者
 *
 * @author zzf
 */
@Component
@Slf4j
public class SendTemplateConsumer {

    @Resource
    private MpTemplateService mpTemplateService;

    @EventListener
    @Async // Spring Event 默认在 Producer 发送的线程，通过 @Async 实现异步
    public void onMessage(SendTemplateMessage message) {

        mpTemplateService.systemSendTemplateMsg(message);
    }

}
